package ar.com.sgsvm.view.articulo;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import ar.com.sgsvm.R;
import ar.com.sgsvm.entity.Articulo;

public class ArticuloAdapter extends BaseAdapter {

	private Context mContext;
	private List<Articulo> mArticulo;

	public ArticuloAdapter(Context context, List<Articulo> articulos) {
		mContext = context;
		mArticulo = articulos;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mArticulo.size();
	}

	@Override
	public Articulo getItem(int position) {
		// TODO Auto-generated method stub
		return mArticulo.get(position);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup group) { // carga
																			// lo
																			// que
																			// se
																			// ve
																			// en
																			// pantalla
		// return View.inflate(context, resource, root)
		// TODO Auto-generated method stub
		View articuloItem = View.inflate(mContext, R.layout.lyt_articulo, null); // se
																					// carga
																					// el
																					// xml
																					// en
																					// el
																					// view,
																					// "se infla la lista de articulos"
		TextView txtCodigo = (TextView) articuloItem.findViewById(R.id.txtCodigo);
		TextView txtDescripcion = (TextView) articuloItem.findViewById(R.id.txtDescripcion);
		TextView txtStock = (TextView) articuloItem.findViewById(R.id.txtStock);

		Articulo articulo = getItem(position);
		txtCodigo.setText(String.valueOf(articulo.getIdArticulo()));
		txtDescripcion.setTag(articulo.getDescripcion());
		txtStock.setText(String.valueOf(articulo.getStock()));

		return articuloItem;
	} // baseAdapter

}
